﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace davejk.Minecraft.ServerWrapper.Utils
{
    public static class Ops
    {
        private static string OpsFile
        {
            get
            {
                return
                    SetupHelper.AppBaseDirectory + "\\Minecraft\\ops.txt";
            }
        }

        public static string[] GetOps()
        {
            TextReader tr = new StreamReader(OpsFile);
            List<string> OpList = new List<string>();
            string line;
            while((line = tr.ReadLine()) != null) {
                OpList.Add(line);
            }
            tr.Close();
            return OpList.ToArray();
        }

        public static bool IsOp(string name)
        {
            TextReader tr = new StreamReader(OpsFile);
            string line;
            while ((line = tr.ReadLine()) != null)
            {
                if (line.ToLower() == name.ToLower())
                {
                    tr.Close();
                    return true;
                }
            }
            tr.Close();
            return false;
        }
    }
}
